
package com.kingdee.eas.custom.aoyuan.aytime.basedata.web;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.waf.annotation.IBOSBizCtrl;
import com.kingdee.bos.waf.util.OperateState;
import com.kingdee.bos.waf.winlet.edit.EditBean;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ICoreBase;
import org.operamasks.faces.annotation.Accessible;
import org.operamasks.faces.component.form.impl.*;
import com.kingdee.bos.waf.action.AbstractWebAction;
import javax.faces.event.AbortProcessingException;
import javax.faces.context.FacesContext;
import org.operamasks.faces.component.action.ActionEvent;
import org.operamasks.faces.annotation.Action;
import com.kingdee.bos.waf.winlet.BaseBean;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;

import com.kingdee.eas.custom.aoyuan.aytime.basedata.ISchedulePerson;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.SchedulePersonInfo;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.SchedulePersonEntryInfo;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.SchedulePersonEntryCollection;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.SchedulePersonSpecSchlInfo;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.SchedulePersonSpecSchlCollection;

public abstract class AbstractSchedulePersonEditUIBean extends com.kingdee.bos.waf.winlet.edit.EditBean {

	@IBOSBizCtrl
	protected com.kingdee.eas.custom.aoyuan.aytime.basedata.ISchedulePerson service;

	@Inject("custom.aoyuan.aytime.basedata.SchedulePersonEntryBean")
	protected SchedulePersonEntryBean schedulePersonEntryBean;
	@Inject("custom.aoyuan.aytime.basedata.SchedulePersonSpecSchlBean")
	protected SchedulePersonSpecSchlBean schedulePersonSpecSchlBean;
	public AbstractSchedulePersonEditUIBean() {
		super();
	}

	
	
	@Override
	public void createNewModel() {
		model = new SchedulePersonInfo();
	}

	@Override
	public void pageOnload() {
		super.pageOnload();
		
		SchedulePersonEntryCollection entryCol_0 = ((SchedulePersonInfo) model).getEntrys();

		List<CoreBaseInfo> listModel_0 = new LinkedList<CoreBaseInfo>();
		if (entryCol_0 != null)
		{
			for (int i = 0, n = entryCol_0.size(); i < n; i++) {
				listModel_0.add(entryCol_0.get(i));
			}
	
			schedulePersonEntryBean.setListModel(listModel_0);
		}

		SchedulePersonSpecSchlCollection entryCol_1 = ((SchedulePersonInfo) model).getSpecSchl();

		List<CoreBaseInfo> listModel_1 = new LinkedList<CoreBaseInfo>();
		if (entryCol_1 != null)
		{
			for (int i = 0, n = entryCol_1.size(); i < n; i++) {
				listModel_1.add(entryCol_1.get(i));
			}
	
			schedulePersonSpecSchlBean.setListModel(listModel_1);
		}

		
	}

	@Override
	public void saveModel() {
		updateModel();
		super.saveModel();
	}

	@Override
	public void submitModel() {
		updateModel();
		super.submitModel();
	}


	protected void updateModel() {
		
		if (schedulePersonEntryBean == null)
			schedulePersonEntryBean = (SchedulePersonEntryBean) com.kingdee.bos.waf.util.BeanUtil
					.getBean("custom.aoyuan.aytime.basedata.SchedulePersonEntryBean");

		schedulePersonEntryBean.updataModel();
		List<CoreBaseInfo> entryModel_0 = schedulePersonEntryBean.getListModel();
		((SchedulePersonInfo) model).getEntrys().clear();
		if (entryModel_0 != null) {
			for (CoreBaseInfo entryInfo : entryModel_0) {
				((SchedulePersonInfo) model).getEntrys().add(
						(SchedulePersonEntryInfo) entryInfo);
			}
		}		
		if (schedulePersonSpecSchlBean == null)
			schedulePersonSpecSchlBean = (SchedulePersonSpecSchlBean) com.kingdee.bos.waf.util.BeanUtil
					.getBean("custom.aoyuan.aytime.basedata.SchedulePersonSpecSchlBean");

		schedulePersonSpecSchlBean.updataModel();
		List<CoreBaseInfo> entryModel_1 = schedulePersonSpecSchlBean.getListModel();
		((SchedulePersonInfo) model).getSpecSchl().clear();
		if (entryModel_1 != null) {
			for (CoreBaseInfo entryInfo : entryModel_1) {
				((SchedulePersonInfo) model).getSpecSchl().add(
						(SchedulePersonSpecSchlInfo) entryInfo);
			}
		}

	}
	
	
	//entry
	public void schedulePersonEntryBean_apendRow(){
		schedulePersonEntryBean.appendRow();
	}
	public void schedulePersonEntryBean_removeRow(){
		schedulePersonEntryBean.removeRow();
	}
	
	//entry
	public void schedulePersonSpecSchlBean_apendRow(){
		schedulePersonSpecSchlBean.appendRow();
	}
	public void schedulePersonSpecSchlBean_removeRow(){
		schedulePersonSpecSchlBean.removeRow();
	}
		

	@Override
	protected ICoreBase getBizInterface() {
		return service;
	}
	
	@Override
	public IMetaDataPK getMetaDataPK() {
		return new MetaDataPK("com.kingdee.eas.custom.aoyuan.aytime.basedata.web.SchedulePersonEditUI");
	}
	
	@Override
	protected String getEntryPKName() {
	
		return "entrys.id";
	
	}

	@Override
	public SelectorItemCollection getSelectors() {
		SelectorItemCollection sic = super.getSelectors();
        sic.add(new SelectorItemInfo("SpecSchl.id"));
        sic.add(new SelectorItemInfo("SpecSchl.seq"));
        sic.add(new SelectorItemInfo("SpecSchl.dept.*"));
        sic.add(new SelectorItemInfo("SpecSchl.position.*"));
        sic.add(new SelectorItemInfo("SpecSchl.emp.*"));
        sic.add(new SelectorItemInfo("SpecSchl.schgroup.*"));
        sic.add(new SelectorItemInfo("SpecSchl.remark"));
        sic.add(new SelectorItemInfo("number"));
        sic.add(new SelectorItemInfo("bizDate"));
        sic.add(new SelectorItemInfo("handler.*"));
        sic.add(new SelectorItemInfo("description"));
        sic.add(new SelectorItemInfo("auditor.*"));
        sic.add(new SelectorItemInfo("entrys.id"));
        sic.add(new SelectorItemInfo("entrys.dept.*"));
        sic.add(new SelectorItemInfo("entrys.position.*"));
        sic.add(new SelectorItemInfo("entrys.emp.*"));
        sic.add(new SelectorItemInfo("entrys.remark"));
        sic.add(new SelectorItemInfo("DefaultSchlGroup.*"));
	
		return sic;
	}			
    	protected String getTDTemplateName() {
	    	return "/bim/custom/aoyuan/aytime/basedata/SchedulePerson";
		}
	    protected com.kingdee.bos.metadata.IMetaDataPK getTDQueryPK() {
	    	return new com.kingdee.bos.metadata.MetaDataPK("com.kingdee.eas.custom.aoyuan.aytime.basedata.app.SchedulePersonQuery");
	    }

}
